home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Editions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  14.9 KB  |  420 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Editions.h
  3.  
  4.      Contains:    Edition Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __EDITIONS__
  21. #define __EDITIONS__
  22.  
  23.  
  24. #ifndef __MEMORY__
  25. #include <Memory.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30.  
  31. #ifndef __TYPES__
  32. #include <Types.h>
  33. #endif
  34.  
  35. #ifndef __FILES__
  36. #include <Files.h>
  37. #endif
  38. /*    #include <OSUtils.h>                                        */
  39.  
  40. #ifndef __ALIASES__
  41. #include <Aliases.h>
  42. #endif
  43. /*    #include <AppleTalk.h>                                        */
  44.  
  45. #ifndef __DIALOGS__
  46. #include <Dialogs.h>
  47. #endif
  48. /*    #include <Errors.h>                                            */
  49. /*    #include <Windows.h>                                        */
  50. /*        #include <Quickdraw.h>                                    */
  51. /*            #include <QuickdrawText.h>                            */
  52. /*        #include <Events.h>                                        */
  53. /*        #include <Controls.h>                                    */
  54. /*            #include <Menus.h>                                    */
  55. /*    #include <TextEdit.h>                                        */
  56.  
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60.  
  61. #if PRAGMA_ALIGN_SUPPORTED
  62. #pragma options align=mac68k
  63. #endif
  64.  
  65. #if PRAGMA_IMPORT_SUPPORTED
  66. #pragma import on
  67. #endif
  68.  
  69.  
  70. enum {
  71. /* resource types  */
  72.     rSectionType                = 'sect',                        /* ResType of saved SectionRecords */
  73. /* Finder types for edition files */
  74.     kPICTEditionFileType        = 'edtp',
  75.     kTEXTEditionFileType        = 'edtt',
  76.     ksndEditionFileType            = 'edts',
  77.     kUnknownEditionFileType        = 'edtu',
  78.     kPublisherDocAliasFormat    = 'alis',
  79.     kPreviewFormat                = 'prvw',
  80.     kFormatListFormat            = 'fmts'
  81. };
  82.  
  83. enum {
  84. /* section types */
  85.     stSubscriber                = 0x01,
  86.     stPublisher                    = 0x0A,
  87.     sumAutomatic                = 0,                            /* subscriber update mode - Automatically     */
  88.     sumManual                    = 1,                            /* subscriber update mode - Manually */
  89.     pumOnSave                    = 0,                            /* publisher update mode - OnSave            */
  90.     pumManual                    = 1,                            /* publisher update mode - Manually */
  91.     kPartsNotUsed                = 0,
  92.     kPartNumberUnknown            = -1,                            /* misc */
  93.     kPreviewWidth                = 120,
  94.     kPreviewHeight                = 120,
  95. /* bits for formatsMask */
  96.     kPICTformatMask                = 1,
  97.     kTEXTformatMask                = 2,
  98.     ksndFormatMask                = 4,
  99. /* pseudo-item hits for dialogHooks 
  100.  the first if for NewPublisher or NewSubscriber Dialogs */
  101.     emHookRedrawPreview            = 150,
  102. /* the following are for SectionOptions Dialog */
  103.     emHookCancelSection            = 160,
  104.     emHookGoToPublisher            = 161,
  105.     emHookGetEditionNow            = 162,
  106.     emHookSendEditionNow        = 162,
  107.     emHookManualUpdateMode        = 163,
  108.     emHookAutoUpdateMode        = 164
  109. };
  110.  
  111. enum {
  112. /* the refcon field of the dialog record during a modalfilter 
  113.  or dialoghook contains one the following */
  114.     emOptionsDialogRefCon        = 'optn',
  115.     emCancelSectionDialogRefCon    = 'cncl',
  116.     emGoToPubErrDialogRefCon    = 'gerr',
  117.     kFormatLengthUnknown        = -1
  118. };
  119.  
  120. /* one byte, stSubscriber or stPublisher */
  121. typedef SignedByte SectionType;
  122.  
  123. /* seconds since 1904 */
  124. typedef unsigned long TimeStamp;
  125.  
  126. /* similar to ResType */
  127. typedef FourCharCode FormatType;
  128.  
  129. /* used in Edition I/O */
  130. typedef Handle EditionRefNum;
  131.  
  132. /* update modes */
  133. /* sumAutomatic, pumSuspend, etc */
  134. typedef short UpdateMode;
  135.  
  136. typedef struct SectionRecord SectionRecord;
  137.  
  138. typedef SectionRecord *SectionPtr, **SectionHandle;
  139.  
  140. struct SectionRecord {
  141.     SignedByte                        version;                    /* always 0x01 in system 7.0 */
  142.     SectionType                        kind;                        /* stSubscriber or stPublisher */
  143.     UpdateMode                        mode;                        /* auto or manual */
  144.     TimeStamp                        mdDate;                        /* last change in document */
  145.     long                            sectionID;                    /* app. specific, unique per document */
  146.     long                            refCon;                        /* application specific */
  147.     AliasHandle                        alias;                        /* handle to Alias Record */
  148.     long                            subPart;                    /* which part of container file */
  149.     SectionHandle                    nextSection;                /* for linked list of app's Sections */
  150.     Handle                            controlBlock;                /* used internally */
  151.     EditionRefNum                    refNum;                        /* used internally */
  152. };
  153. struct EditionContainerSpec {
  154.     FSSpec                            theFile;
  155.     ScriptCode                        theFileScript;
  156.     long                            thePart;
  157.     Str31                            thePartName;
  158.     ScriptCode                        thePartScript;
  159. };
  160. typedef struct EditionContainerSpec EditionContainerSpec;
  161.  
  162. typedef EditionContainerSpec *EditionContainerSpecPtr;
  163.  
  164. struct EditionInfoRecord {
  165.     TimeStamp                        crDate;                        /* date EditionContainer was created */
  166.     TimeStamp                        mdDate;                        /* date of last change */
  167.     OSType                            fdCreator;                    /* file creator */
  168.     OSType                            fdType;                        /* file type */
  169.     EditionContainerSpec            container;                    /* the Edition */
  170. };
  171. typedef struct EditionInfoRecord EditionInfoRecord;
  172.  
  173. struct NewPublisherReply {
  174.     Boolean                            canceled;                    /* O */
  175.     Boolean                            replacing;
  176.     Boolean                            usePart;                    /* I */
  177.     SInt8                            filler;
  178.     Handle                            preview;                    /* I */
  179.     FormatType                        previewFormat;                /* I */
  180.     EditionContainerSpec            container;                    /* I/O */
  181. };
  182. typedef struct NewPublisherReply NewPublisherReply;
  183.  
  184. struct NewSubscriberReply {
  185.     Boolean                            canceled;                    /* O */
  186.     SignedByte                        formatsMask;
  187.     EditionContainerSpec            container;                    /*I/O*/
  188. };
  189. typedef struct NewSubscriberReply NewSubscriberReply;
  190.  
  191. struct SectionOptionsReply {
  192.     Boolean                            canceled;                    /* O */
  193.     Boolean                            changed;                    /* O */
  194.     SectionHandle                    sectionH;                    /* I */
  195.     ResType                            action;                        /* O */
  196. };
  197. typedef struct SectionOptionsReply SectionOptionsReply;
  198.  
  199. typedef pascal Boolean (*ExpModalFilterProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short itemOffset, short *itemHit, Ptr yourDataPtr);
  200. typedef pascal short (*ExpDlgHookProcPtr)(short itemOffset, short itemHit, DialogPtr theDialog, Ptr yourDataPtr);
  201.  
  202. #if GENERATINGCFM
  203. typedef UniversalProcPtr ExpModalFilterUPP;
  204. typedef UniversalProcPtr ExpDlgHookUPP;
  205. #else
  206. typedef ExpModalFilterProcPtr ExpModalFilterUPP;
  207. typedef ExpDlgHookProcPtr ExpDlgHookUPP;
  208. #endif
  209.  
  210. enum {
  211.     uppExpModalFilterProcInfo = kPascalStackBased
  212.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  213.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  214.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
  215.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  216.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short*)))
  217.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(Ptr))),
  218.     uppExpDlgHookProcInfo = kPascalStackBased
  219.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  220.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  221.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  222.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DialogPtr)))
  223.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Ptr)))
  224. };
  225.  
  226. #if GENERATINGCFM
  227. #define NewExpModalFilterProc(userRoutine)        \
  228.         (ExpModalFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppExpModalFilterProcInfo, GetCurrentArchitecture())
  229. #define NewExpDlgHookProc(userRoutine)        \
  230.         (ExpDlgHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppExpDlgHookProcInfo, GetCurrentArchitecture())
  231. #else
  232. #define NewExpModalFilterProc(userRoutine)        \
  233.         ((ExpModalFilterUPP) (userRoutine))
  234. #define NewExpDlgHookProc(userRoutine)        \
  235.         ((ExpDlgHookUPP) (userRoutine))
  236. #endif
  237.  
  238. #if GENERATINGCFM
  239. #define CallExpModalFilterProc(userRoutine, theDialog, theEvent, itemOffset, itemHit, yourDataPtr)        \
  240.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppExpModalFilterProcInfo, (theDialog), (theEvent), (itemOffset), (itemHit), (yourDataPtr))
  241. #define CallExpDlgHookProc(userRoutine, itemOffset, itemHit, theDialog, yourDataPtr)        \
  242.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppExpDlgHookProcInfo, (itemOffset), (itemHit), (theDialog), (yourDataPtr))
  243. #else
  244. #define CallExpModalFilterProc(userRoutine, theDialog, theEvent, itemOffset, itemHit, yourDataPtr)        \
  245.         (*(userRoutine))((theDialog), (theEvent), (itemOffset), (itemHit), (yourDataPtr))
  246. #define CallExpDlgHookProc(userRoutine, itemOffset, itemHit, theDialog, yourDataPtr)        \
  247.         (*(userRoutine))((itemOffset), (itemHit), (theDialog), (yourDataPtr))
  248. #endif
  249.  
  250.  
  251. enum {
  252.     ioHasFormat,
  253.     ioReadFormat,
  254.     ioNewFormat,
  255.     ioWriteFormat
  256. };
  257.  
  258. typedef SignedByte FormatIOVerb;
  259.  
  260.  
  261. enum {
  262.     eoOpen,
  263.     eoClose,
  264.     eoOpenNew,
  265.     eoCloseNew,
  266.     eoCanSubscribe
  267. };
  268.  
  269. typedef SignedByte EditionOpenerVerb;
  270.  
  271. struct FormatIOParamBlock {
  272.     long                            ioRefNum;
  273.     FormatType                        format;
  274.     long                            formatIndex;
  275.     unsigned long                    offset;
  276.     Ptr                                buffPtr;
  277.     unsigned long                    buffLen;
  278. };
  279. typedef struct FormatIOParamBlock FormatIOParamBlock;
  280.  
  281. typedef struct EditionOpenerParamBlock EditionOpenerParamBlock;
  282.  
  283. typedef pascal short (*FormatIOProcPtr)(FormatIOVerb selector, FormatIOParamBlock *PB);
  284. typedef pascal short (*EditionOpenerProcPtr)(EditionOpenerVerb selector, EditionOpenerParamBlock *PB);
  285.  
  286. #if GENERATINGCFM
  287. typedef UniversalProcPtr FormatIOUPP;
  288. typedef UniversalProcPtr EditionOpenerUPP;
  289. #else
  290. typedef FormatIOProcPtr FormatIOUPP;
  291. typedef EditionOpenerProcPtr EditionOpenerUPP;
  292. #endif
  293.  
  294. struct EditionOpenerParamBlock {
  295.     EditionInfoRecord                info;
  296.     SectionHandle                    sectionH;
  297.     const FSSpec                    *document;
  298.     OSType                            fdCreator;
  299.     long                            ioRefNum;
  300.     FormatIOUPP                        ioProc;
  301.     Boolean                            success;
  302.     SignedByte                        formatsMask;
  303. };
  304. enum {
  305.     uppFormatIOProcInfo = kPascalStackBased
  306.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  307.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FormatIOVerb)))
  308.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FormatIOParamBlock*))),
  309.     uppEditionOpenerProcInfo = kPascalStackBased
  310.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  311.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EditionOpenerVerb)))
  312.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EditionOpenerParamBlock*)))
  313. };
  314.  
  315. #if GENERATINGCFM
  316. #define NewFormatIOProc(userRoutine)        \
  317.         (FormatIOUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFormatIOProcInfo, GetCurrentArchitecture())
  318. #define NewEditionOpenerProc(userRoutine)        \
  319.         (EditionOpenerUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppEditionOpenerProcInfo, GetCurrentArchitecture())
  320. #else
  321. #define NewFormatIOProc(userRoutine)        \
  322.         ((FormatIOUPP) (userRoutine))
  323. #define NewEditionOpenerProc(userRoutine)        \
  324.         ((EditionOpenerUPP) (userRoutine))
  325. #endif
  326.  
  327.  
  328. enum {
  329.     sectionEventMsgClass        = 'sect',
  330.     sectionReadMsgID            = 'read',
  331.     sectionWriteMsgID            = 'writ',
  332.     sectionScrollMsgID            = 'scrl',
  333.     sectionCancelMsgID            = 'cncl'
  334. };
  335.  
  336. enum {
  337.     currentEditionMgrVers        = 0x0011
  338. };
  339.  
  340. #if !CFMSYSTEMCALLS
  341. extern pascal OSErr InitEditionPack(void)
  342.  FIVEWORDINLINE(0x3F3C, 0x0011, 0x303C, 0x0100, 0xA82D);
  343. #else
  344. #define InitEditionPack() InitEditionPackVersion(currentEditionMgrVers)
  345. extern pascal OSErr InitEditionPackVersion(short curEditionMgrVers)
  346.  THREEWORDINLINE(0x303C, 0x0100, 0xA82D);
  347. #endif
  348. extern pascal OSErr NewSection(const EditionContainerSpec *container, ConstFSSpecPtr sectionDocument, SectionType kind, long sectionID, UpdateMode initalMode, SectionHandle *sectionH)
  349.  THREEWORDINLINE(0x303C, 0x0A02, 0xA82D);
  350. extern pascal OSErr RegisterSection(const FSSpec *sectionDocument, SectionHandle sectionH, Boolean *aliasWasUpdated)
  351.  THREEWORDINLINE(0x303C, 0x0604, 0xA82D);
  352. extern pascal OSErr UnRegisterSection(SectionHandle sectionH)
  353.  THREEWORDINLINE(0x303C, 0x0206, 0xA82D);
  354. extern pascal OSErr IsRegisteredSection(SectionHandle sectionH)
  355.  THREEWORDINLINE(0x303C, 0x0208, 0xA82D);
  356. extern pascal OSErr AssociateSection(SectionHandle sectionH, const FSSpec *newSectionDocument)
  357.  THREEWORDINLINE(0x303C, 0x040C, 0xA82D);
  358. extern pascal OSErr CreateEditionContainerFile(const FSSpec *editionFile, OSType fdCreator, ScriptCode editionFileNameScript)
  359.  THREEWORDINLINE(0x303C, 0x050E, 0xA82D);
  360. extern pascal OSErr DeleteEditionContainerFile(const FSSpec *editionFile)
  361.  THREEWORDINLINE(0x303C, 0x0210, 0xA82D);
  362. extern pascal OSErr OpenEdition(SectionHandle subscriberSectionH, EditionRefNum *refNum)
  363.  THREEWORDINLINE(0x303C, 0x0412, 0xA82D);
  364. extern pascal OSErr OpenNewEdition(SectionHandle publisherSectionH, OSType fdCreator, ConstFSSpecPtr publisherSectionDocument, EditionRefNum *refNum)
  365.  THREEWORDINLINE(0x303C, 0x0814, 0xA82D);
  366. extern pascal OSErr CloseEdition(EditionRefNum whichEdition, Boolean successful)
  367.  THREEWORDINLINE(0x303C, 0x0316, 0xA82D);
  368. extern pascal OSErr EditionHasFormat(EditionRefNum whichEdition, FormatType whichFormat, Size *formatSize)
  369.  THREEWORDINLINE(0x303C, 0x0618, 0xA82D);
  370. extern pascal OSErr ReadEdition(EditionRefNum whichEdition, FormatType whichFormat, void *buffPtr, Size *buffLen)
  371.  THREEWORDINLINE(0x303C, 0x081A, 0xA82D);
  372. extern pascal OSErr WriteEdition(EditionRefNum whichEdition, FormatType whichFormat, const void *buffPtr, Size buffLen)
  373.  THREEWORDINLINE(0x303C, 0x081C, 0xA82D);
  374. extern pascal OSErr GetEditionFormatMark(EditionRefNum whichEdition, FormatType whichFormat, unsigned long *currentMark)
  375.  THREEWORDINLINE(0x303C, 0x061E, 0xA82D);
  376. extern pascal OSErr SetEditionFormatMark(EditionRefNum whichEdition, FormatType whichFormat, unsigned long setMarkTo)
  377.  THREEWORDINLINE(0x303C, 0x0620, 0xA82D);
  378. extern pascal OSErr GetEditionInfo(SectionHandle sectionH, EditionInfoRecord *editionInfo)
  379.  THREEWORDINLINE(0x303C, 0x0422, 0xA82D);
  380. extern pascal OSErr GoToPublisherSection(const EditionContainerSpec *container)
  381.  THREEWORDINLINE(0x303C, 0x0224, 0xA82D);
  382. extern pascal OSErr GetLastEditionContainerUsed(EditionContainerSpec *container)
  383.  THREEWORDINLINE(0x303C, 0x0226, 0xA82D);
  384. extern pascal OSErr GetStandardFormats(const EditionContainerSpec *container, FormatType *previewFormat, Handle preview, Handle publisherAlias, Handle formats)
  385.  THREEWORDINLINE(0x303C, 0x0A28, 0xA82D);
  386. extern pascal OSErr GetEditionOpenerProc(EditionOpenerUPP *opener)
  387.  THREEWORDINLINE(0x303C, 0x022A, 0xA82D);
  388. extern pascal OSErr SetEditionOpenerProc(EditionOpenerUPP opener)
  389.  THREEWORDINLINE(0x303C, 0x022C, 0xA82D);
  390. extern pascal OSErr CallEditionOpenerProc(EditionOpenerVerb selector, EditionOpenerParamBlock *PB, EditionOpenerUPP routine)
  391.  THREEWORDINLINE(0x303C, 0x052E, 0xA82D);
  392. extern pascal OSErr CallFormatIOProc(FormatIOVerb selector, FormatIOParamBlock *PB, FormatIOUPP routine)
  393.  THREEWORDINLINE(0x303C, 0x0530, 0xA82D);
  394. extern pascal OSErr NewSubscriberDialog(NewSubscriberReply *reply)
  395.  THREEWORDINLINE(0x303C, 0x0232, 0xA82D);
  396. extern pascal OSErr NewSubscriberExpDialog(NewSubscriberReply *reply, Point where, short expansionDITLresID, ExpDlgHookUPP dlgHook, ExpModalFilterUPP filter, void *yourDataPtr)
  397.  THREEWORDINLINE(0x303C, 0x0B34, 0xA82D);
  398. extern pascal OSErr NewPublisherDialog(NewPublisherReply *reply)
  399.  THREEWORDINLINE(0x303C, 0x0236, 0xA82D);
  400. extern pascal OSErr NewPublisherExpDialog(NewPublisherReply *reply, Point where, short expansionDITLresID, ExpDlgHookUPP dlgHook, ExpModalFilterUPP filter, void *yourDataPtr)
  401.  THREEWORDINLINE(0x303C, 0x0B38, 0xA82D);
  402. extern pascal OSErr SectionOptionsDialog(SectionOptionsReply *reply)
  403.  THREEWORDINLINE(0x303C, 0x023A, 0xA82D);
  404. extern pascal OSErr SectionOptionsExpDialog(SectionOptionsReply *reply, Point where, short expansionDITLresID, ExpDlgHookUPP dlgHook, ExpModalFilterUPP filter, void *yourDataPtr)
  405.  THREEWORDINLINE(0x303C, 0x0B3C, 0xA82D);
  406.  
  407. #if PRAGMA_IMPORT_SUPPORTED
  408. #pragma import off
  409. #endif
  410.  
  411. #if PRAGMA_ALIGN_SUPPORTED
  412. #pragma options align=reset
  413. #endif
  414.  
  415. #ifdef __cplusplus
  416. }
  417. #endif
  418.  
  419. #endif /* __EDITIONS__ */
  420.